package com.glela.controller;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.glela.platform.constant.ErrorEnum;
import com.glela.platform.model.response.ResponseAdConfig;
import com.glela.platform.model.response.ResponseBaseModel;
import com.glela.platform.model.response.ResponseResultModel;
import com.glela.platform.service.AdConfigService;

@Controller
@RequestMapping("/ad")
public class AdConfigController
{

	private static final Logger logger = LoggerFactory.getLogger(AdConfigController.class);

	@Autowired
	private AdConfigService adConfigService;

	@RequestMapping(value="/getList")
	public @ResponseBody ResponseEntity<?> getList(){
		try {
			List<ResponseAdConfig> list = adConfigService.findAll2Response();
			return new ResponseEntity<>(new ResponseResultModel<List<ResponseAdConfig>>(list), HttpStatus.OK);
		} catch (Exception e) {
			logger.error("查询广告列表异常:" +e);
			return new ResponseEntity<>(new ResponseBaseModel(ErrorEnum.C20000), HttpStatus.OK);
		}
	}
}
